// 
//  JoinPacket.cs
//  
//  Author:
//       Christian Winkel <alphawolf1988@gmail.com>
//  
//  Copyright (c) 2012 
// 
//  This program is free software: you can redistribute it and/or modify
//  it under the terms of the GNU Lesser General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.
// 
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU Lesser General Public License for more details.
// 
//  You should have received a copy of the GNU Lesser General Public License
//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
using System;
using Lypshare.Net;

namespace Lypshare.ChatApp.Packets
{
	/// <summary>
	/// Join packet.
	/// </summary>
	/// <exception cref='ArgumentNullException'>
	/// Is thrown when an argument passed to a method is invalid because it is <see langword="null" /> .
	/// </exception>
	public class JoinPacket : Packet
	{
		// --------------------------------------------------------
        // Class Properties
        // --------------------------------------------------------


        /// <summary>
        /// Gets or sets the name.
        /// </summary>
        /// <value>
        /// The name.
        /// </value>
        public String Name
        {
            get;
            set;

        } // Property: Name


        // --------------------------------------------------------
        // Class Functions
        // --------------------------------------------------------


        /// <summary>
        /// Initializes a new instance of the <see cref="Lypshare.ChatApp.Packets.JoinPacket"/> class.
        /// </summary>
        public JoinPacket()
        {
        } // Constructor


        /// <summary>
        /// Initializes a new instance of the <see cref="Lypshare.ChatApp.Packets.JoinPacket"/> class.
        /// </summary>
        /// <param name='name'>
        /// Name.
        /// </param>
        /// <exception cref='ArgumentNullException'>
        /// Is thrown when an argument passed to a method is invalid because it is <see langword="null" /> .
        /// </exception>
        public JoinPacket(String name)
        {
            if (name == null)
                throw new ArgumentNullException("name");

            Name = name;

        } // Constructor


        /// <summary>
        /// Parse the specified buffer.
        /// </summary>
        /// <param name='buffer'>
        /// Buffer.
        /// </param>
        /// <exception cref='ArgumentNullException'>
        /// Is thrown when an argument passed to a method is invalid because it is <see langword="null" /> .
        /// </exception>
        protected override void Parse(PacketBuffer buffer)
        {
			if(buffer == null)
				throw new ArgumentNullException("buffer");
			
            Name = buffer.ReadString();
            base.Parse(buffer);

        } // Parse


        /// <summary>
        /// Encode the specified buffer.
        /// </summary>
        /// <param name='buffer'>
        /// Buffer.
        /// </param>
        /// <exception cref='ArgumentNullException'>
        /// Is thrown when an argument passed to a method is invalid because it is <see langword="null" /> .
        /// </exception>
        protected override void Encode(PacketBuffer buffer)
        {
			if(buffer == null)
				throw new ArgumentNullException("buffer");
			
            buffer.Write(Name);
            base.Encode(buffer);

        } // Encode
		
	} // class JoinPacket
} // namespace Lypshare.ChatApp.Packets